package com.gdufe.studytogether.controller;

import com.gdufe.studytogether.domain.R;
import com.gdufe.studytogether.domain.pojo.Application;
import com.gdufe.studytogether.service.application.ApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/application")
public class ApplicationController {
    @Autowired
    ApplicationService applicationService;

    @GetMapping("/list")
    public R getApplication() throws Exception {
        return applicationService.getApplication();
    }

    @PostMapping("/add")
    public R applicateJoinGroup(@RequestBody Application application) throws Exception {
       return applicationService.addApplication(application);
    }

    @GetMapping("/agree")
    public R agreeApplication(Integer id) throws Exception {
        return applicationService.agreeApplication(id);
    }

    @GetMapping("/disagree")
    public R disagreeApplication(Integer id) throws Exception {
        return applicationService.disagreeApplication(id);
    }

    @GetMapping("/delete")
    public R deleteApplication(Integer id) throws Exception {
        return applicationService.deleteApplication(id);
    }

}
